home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / CDICTION / CSMARTBU.C < prev    next >
Text File  |  1989-09-15  |  3KB  |  100 lines

  1. /*****************************************************************************
  2. CSmartButton.c
  3.  
  4.     see header for more information
  5.     
  6. SUPERCLASS = CButton
  7. *****************************************************************************/
  8.  
  9.  
  10. #include "CSmartButton.h"
  11. #include "CSmartWindow.h"
  12.  
  13. /*****************************************************************************/
  14. void CSmartButton::ISmartButton(Int16 CNTLid, CView *anEnclosure,
  15.                     CBureaucrat    *aSupervisor)
  16. {
  17.     CButton::IButton( CNTLid, anEnclosure, aSupervisor);
  18.     enabled = TRUE;
  19.     
  20.     SetClickCmd( GetCRefCon( macControl));
  21.  
  22. }    /* CSmartButton::ISmartButton */
  23. /*****************************************************************************/
  24. void CSmartButton::Draw( Rect *area)
  25. {
  26.     CSmartWindow    *window;
  27.     
  28.     if (GetCVariant( macControl) >= useWFont)
  29.     {
  30.         window = (CSmartWindow *) GetWRefCon( macPort);
  31.         if (member( window, CSmartWindow))
  32.             window->RestoreEnvirons();
  33.     }
  34.     inherited::Draw( area);
  35.  
  36. }    /* CSmartButton::Draw */
  37. /*****************************************************************************/
  38. void CSmartButton::Enable( void)
  39. {
  40.     if (!enabled)
  41.     {
  42.         enabled = TRUE;
  43.         CControl::Activate();
  44.     }
  45.  
  46. }    /* CSmartButton::Enable */
  47. /*****************************************************************************/
  48. void CSmartButton::Disable( void)
  49. {
  50.     if (enabled)
  51.     {
  52.         enabled = FALSE;
  53.         CControl::Deactivate();
  54.     }
  55.  
  56. }    /* CSmartButton::Disable */
  57. /*****************************************************************************/
  58. void CSmartButton::SetEnable( Int16 enableFlag)
  59. {
  60.     if (enableFlag) Enable(); else Disable();
  61.  
  62. }    /* CSmartButton::SetEnable */
  63. /*****************************************************************************/
  64. void CSmartButton::Activate( void)
  65. {
  66.     Rect            tempRect;
  67.     
  68.     /* don't call inherited, because it doesn't let non-rectangular
  69.         controls on non-white backgrounds draw properly */
  70.         
  71.     if ((enabled)&&(ReallyVisible()))
  72.     {
  73.         if (!active) {
  74.             active = TRUE;
  75.             
  76.             Prepare();                        /* Tell Mac Control Manager to        */
  77.             HidePen();                        /*   activate the control but        */
  78.             HiliteControl(macControl, 0);    /*   suppress the automatic drawing    */
  79.             ShowPen();
  80.             
  81.             Refresh();        /* invalidate instead of drawing */
  82.             
  83.         }
  84.     }
  85.  
  86. }    /* SmartControl::Activate */
  87. /*****************************************************************************/
  88. void CSmartButton::Deactivate( void)
  89. {
  90.     if ((enabled)&&(ReallyVisible())) inherited::Deactivate();
  91.  
  92. }    /* CSmartButton::Deactivate */
  93. /*****************************************************************************/
  94.  void CSmartButton::SetHilite( Int16 hiliteVal)
  95. {
  96.     HiliteControl( macControl, hiliteVal);
  97.  
  98. }    /* CSmartButton::SetHilite */
  99. /*****************************************************************************/
  100.